package com.xiaoma.reflection;

import com.xiaoma.base.ref.User;
import java.lang.reflect.Field;
import java.util.Arrays;

/**
 *
 * @ClassName Test
 * @Description
 * @date 2020-09-21 20:11
 */
public class Test {

  // https://blog.csdn.net/fengyuzhengfan/article/details/38086743?utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromMachineLearnPai2%7Edefault-1.vipsorttest&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromMachineLearnPai2%7Edefault-1.vipsorttest
  // -verbose:class 加载过程
  public static void main(String[] args) throws ClassNotFoundException {
    User user=new User();//在new 的时候会加载类，并不是将所有的class字节码加载到虚拟机
    Class<?> name = Class.forName("com.xiaoma.base.ref.User");//Class.forName也会类加载
    Field[] declaredFields = name.getDeclaredFields();
    System.out.println(Arrays.asList(declaredFields));
    System.out.println(name);
  }

}
